<?php
/**
 * Created on 2011-06-17
 *
 * @package core
 * @author xiamingran
 * @version 1.0
 *
 */
class AppClassLoader
{
    static $classMap = array();

    static function init() {

        $publicClassesFile = CORE_ROOT . '/config/classes_path.cfg.php';
        $appClassesFile = APPLICATION_ROOT . '/config/classes_path.cfg.php';

        try {

            self::$classMap = @include $publicClassesFile;

            if (file_exists($appClassesFile)) {
            	$appClasses = @include $appClassesFile;
            	self::$classMap = array_merge(self::$classMap,$appClasses);
            }

        } catch (Exception $e) {
            //do nothing
        }

        spl_autoload_register(array(__CLASS__, 'load'));
    }

    static function load($class) {

    	$class = strtolower($class);
    	if (isset(self::$classMap[$class])) {
            require self::$classMap[$class];
        }
    }



}
AppClassLoader::init();
